In [1]:
function min( a )
table.sort( a )
return a[1]
end
function max( a )
table.sort( a )
return a[#a]
end
function mean( a )
local sum = 0
local count= 0
for i, x in ipairs(a) do
sum = sum + x
count = count + 1
end
return (sum / count)
end
function median( a )
table.sort( a )
if math.fmod(#a,2) == 0 then
-- return mean value of middle two elements
return ( a[#a/2] + a[(#a/2)+1] ) / 2
else
-- return middle element
return a[math.ceil(#a/2)]
end
end
function stats( a )
return string.format("min: %.4f, max: %.4f, mean: %.4f, median: %.4f", min(a), max(a), mean(a), median(a))
end
In [2]:
ok, reason = splash:go('http://scrapy.org/')
Wait until page is loaded
In [3]:
a = {}
for i=1,100 do
local x = os.clock()
splash:png()
a[i] = os.clock() - x
end
stats(a)
Out[3]:
In [4]:
a = {}
for i=1,100 do
local x = os.clock()
splash:jpeg()
a[i] = os.clock() - x
end
stats(a)
Out[4]:
In [5]:
a = {}
for i=1,100 do
local x = os.clock()
splash:jpeg{quality=100}
a[i] = os.clock() - x
end
stats(a)
Out[5]:
In [6]:
a = {}
for i=1,100 do
local x = os.clock()
splash:jpeg{quality=90}
a[i] = os.clock() - x
end
stats(a)
Out[6]:
In [7]:
a = {}
for i=1,100 do
local x = os.clock()
splash:jpeg{quality=10}
a[i] = os.clock() - x
end
stats(a)
Out[7]:
In [8]:
a = {}
for i=1,100 do
local x = os.clock()
splash:jpeg{quality=0}
a[i] = os.clock() - x
end
stats(a)
Out[8]:
In [ ]:
splash:go('https://blog.pinterest.com/en')
Wait until page is loaded
In [10]:
a = {}
for i=1,100 do
local x = os.clock()
splash:png{render_all=1}
a[i] = os.clock() - x
end
stats(a)
Out[10]:
In [11]:
a = {}
for i=1,100 do
local x = os.clock()
splash:jpeg{render_all=1}
a[i] = os.clock() - x
end
stats(a)
Out[11]:
In [12]:
a = {}
for i=1,100 do
local x = os.clock()
splash:jpeg{render_all=1, quality=90}
a[i] = os.clock() - x
end
stats(a)
Out[12]:
In [13]:
splash:go('http://www.w3.org/TR/2010/REC-xhtml-basic-20101123/')
Out[13]:
Wait until page is fully loaded
In [14]:
a = {}
for i=1,100 do
local x = os.clock()
splash:png{render_all=1}
a[i] = os.clock() - x
end
stats(a)
Out[14]:
In [15]:
a = {}
for i=1,100 do
local x = os.clock()
splash:jpeg{render_all=1}
a[i] = os.clock() - x
end
stats(a)
Out[15]:
In [16]:
a = {}
for i=1,100 do
local x = os.clock()
splash:jpeg{render_all=1, quality=90}
a[i] = os.clock() - x
end
stats(a)
Out[16]: